package com.cskaoyan.controller;

import com.cskaoyan.bean.VO.WxHomeAboutVO;
import com.cskaoyan.bean.VO.WxHomeIndexVO;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.properties.VxAboutDatasourceProperties;
import com.cskaoyan.service.WxHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wenkaikai
 * @since 2022/08/16 08:58
 */

@RestController
@RequestMapping("wx/home")
public class WxHomeController {


    @Autowired
    WxHomeService wxHomeService;

    @Autowired
    VxAboutDatasourceProperties properties;

    /**
     * 个人页，关于我们
     * 不访问数据库直接从配置文件拿
     *
     * @return
     */
    @RequestMapping("about")
    public BaseRespVo about() {
        WxHomeAboutVO data = new WxHomeAboutVO(properties.getAddress(), properties.getLatitude(), properties.getLongitude(),
                properties.getName(), properties.getPhone(), properties.getQq());
        return BaseRespVo.ok(0, data, "成功");
    }

    /**
     * 第一次进入小程序加载主页内容
     * 无请求参数
     *
     * @return
     */
    @RequestMapping("index")
    public BaseRespVo index() {
        WxHomeIndexVO wxHomeIndexVO = wxHomeService.queryHomeIndex();
        return BaseRespVo.ok(0, wxHomeIndexVO, "成功");
    }

    /**
     * 没找到请求，先不写
     *
     * @return
     */
    @RequestMapping("cache")
    public BaseRespVo cache() {
        return BaseRespVo.ok("成功");
    }
}